/*
ID: icerupt1
PROG: palsquare
LANG: C++11
*/
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;

string base_change(int x, int b)
{
	string s = "";
	while (x) {
		if (x%b >= 10) s += 'A' + x%b - 10;
		else		   s += '0' + x%b;
		x /= b;
	}
	reverse(s.begin(), s.end());
	return s;
}

bool is_palsquare(string s)
{
	return s == string(s.rbegin(), s.rend());
}

int main()
{
	ifstream fin {"palsquare.in" };
	ofstream fout{"palsquare.out"};
	int b;
	fin >> b;
	for (int i = 1; i <= 300; i++)
		if (is_palsquare(base_change(i*i, b)))
			fout << base_change(i, b) << " " << base_change(i*i, b) << "\n";
}

